package com.huluobo.a2301mdmdemo.video

import com.huluobo.a2301mdmdemo.video.entity.CommentEntity
import com.huluobo.a2301mdmdemo.video.entity.VideoEntity
import com.huluobo.lib_base.BaseRepo
import com.huluobo.lib_base.Res
import com.huluobo.lib_http.HttpType
import com.huluobo.lib_http.NetworkFactory
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 *  Created by LC on 2025/7/3.
 */
class VideoRepo @Inject constructor() : BaseRepo() {
    private val apiService by lazy { NetworkFactory.factory(HttpType.VIDEO).create(ApiService::class.java) }

    fun getVideos(currentPage: Int, pageSize: Int): Flow<Res<VideoEntity>> {
        return apiService.getVideos(currentPage, pageSize)
    }

    fun likeVideo(videoId: Int): Flow<Res<Any>> {
        return apiService.likeVideo(videoId = videoId)
    }

    fun noLikeVideo(videoId: Int): Flow<Res<Any>> {
        return apiService.noLikeVideo(videoId = videoId)
    }

    fun getComments(videoId: Int): Flow<Res<CommentEntity>> {
        return apiService.getComments(videoId)
    }

    fun sendComment(map: Map<String, Any>): Flow<Res<CommentEntity>> {
        return apiService.sendComment(mapToJson(map))
    }
}